/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * {{get_generation_time()}}
 * {{get_project_name()}}
 * {{get_vcos_version()}}
 * Description:  1145的动态代码文件
 */

#ifndef CANTRCV1145_CFG_H_
#define CANTRCV1145_CFG_H_
#ifdef __cplusplus
extern "C" {
#endif

#include "comstack_types.h"
#include "can_generaltypes.h"

#include "cantrcv_tja1145_types.h"

{%- if 'VCOS_MODULE_CONFIG_SPI' in sys_cfg['modules_info']['kfg_module_all_list'] and sys_cfg['modules_info']['kfg_module_all_list']['VCOS_MODULE_CONFIG_SPI'] == 'y' %}
#include "Spi.h"
{%- endif %}

{%- if 'VCOS_MODULE_CONFIG_CANIF' in sys_cfg['modules_info']['kfg_module_all_list'] and sys_cfg['modules_info']['kfg_module_all_list']['VCOS_MODULE_CONFIG_CANIF'] == 'y' %}
#include "CanIf.h"
{%- endif %}

{%- if 'VCOS_MODULE_CONFIG_ECUM' in sys_cfg['modules_info']['kfg_module_all_list'] and sys_cfg['modules_info']['kfg_module_all_list']['VCOS_MODULE_CONFIG_ECUM'] == 'y' %}
#include "EcuM_Cbk.h"
#include "EcuM_Types.h"
{%- else %}
#ifndef EcuM_WakeupSourceType
typedef uint32 EcuM_WakeupSourceType;
#endif
{%- endif %}

#define CANTRCV_TJA1145_INSTANCE_ID                       ({{CanTrcvGeneral["CanTrcvIndex"]}}u)

#define CANTRCV_TJA1145_MAX_CHANNEL                       ({{CanTrcvChannel | length}}u)

#define CANTRCV_GENERAL_WK_EN           {{CanTrcvGeneral["CanTrcvWakeUpSupport"]}}
#define CANTRCV_TJA1145_GET_VERSION_INFO                  {{CanTrcvGeneral["CanTrcvGetVersionInfo"]}}
#define CANTRCV_TJA1145_DEV_ERROR_DETECT                  {{CanTrcvGeneral["CanTrcvDevErrorDetect"]}}

#define CANTRCV_TJA1145_SET_OP_MODE_WAIT_TIME_SUPPORT     {{CanTrcvGeneral["CanTrcvWaitTimeSupport"]}}
#define CANTRCV_TJA1145_SET_OP_MODE_ANY_WAIT_TIME_USEC    ({{CanTrcvGeneral["CanTrcvWaitTime"]}}u)

#define CANTRCV_Wk_BY_BUS                {{CanTrcvConfigSet["wakeuUpByBusUsed"]}}
#define CANTRCV_TJA1145_BUS_ERR_FLAG                      {{CanTrcvConfigSet["bussErrFlag"]}}
#define CANTRCV_TJA1145_FD_TOLERANCE                      {{CanTrcvConfigSet["fdTolerance"]}}
#define CANTRCV_TJA1145_USE_EXTENDED_WU_SRC               {{CanTrcvConfigSet["usedExtendedWakeUpSrc"]}}
#define CANTRCV_TJA1145_VERIFY_DATA                       STD_ON

{% for chnlName, chnlAttr in CanTrcvChannel.items() %}
#define CanTrcv_Tja1145_{{chnlName}}  {{ "(%su)" | format(loop.index - 1) }}
{% endfor %}

#define CANTRCV1145_START_SEC_CONST
#include "cantrcv1145_memmap.h"

/* global config data */
extern CONST(cantrcv_channel_cate, CANTRCV1145_CONST) CanTrcv_Tja1145_ChannelUsed[CANTRCV_TJA1145_MAX_CHANNEL];

extern CONST(CanTrcv_TrcvModeType, CANTRCV1145_CONST) CanTrcv_Tja1145_ChannelInitState[CANTRCV_TJA1145_MAX_CHANNEL];

extern CONST(cantrcv_fd_tolerance_en_cate, CANTRCV1145_CONST) CanTrcv_Tja1145_FdToleranceEnabled[CANTRCV_TJA1145_MAX_CHANNEL];

extern CONST(cantrcv_wakeup_bus_cate, CANTRCV1145_CONST) CanTrcv_Tja1145_WakeupByBusUsed[CANTRCV_TJA1145_MAX_CHANNEL];

extern CONST(cantrcv_wakeup_src_cate, CANTRCV1145_CONST) CanTrcv_Tja1145_WakeupSource[CANTRCV_TJA1145_MAX_CHANNEL];

extern CONST(cantrcv_wakeup_src_port_cate, CANTRCV1145_CONST) CanTrcv_Tja1145_WuSrcPor[CANTRCV_TJA1145_MAX_CHANNEL];

extern CONST(cantrcv_wk_src_err_cate, CANTRCV1145_CONST) CanTrcv_Tja1145_WuSrcSyserr[CANTRCV_TJA1145_MAX_CHANNEL];

extern CONST(cantrcv_cfg_t, CANTRCV1145_CONST) CanTrcv_Tja1145_InitConfig;

#define CANTRCV1145_STOP_SEC_CONST
#include "cantrcv1145_memmap.h"

/* CanTrcv_Tja1145 Get Data Macros  */
#define CanTrcv_Tja1145_IsChannelUsed(Index)                       ((CanTrcv_Tja1145_ChannelUsed[(Index)]) != FALSE)
#define CanTrcv_Tja1145_IsFdToleranceEnabled(Index)          ((CanTrcv_Tja1145_FdToleranceEnabled[(Index)]) != FALSE)
#define CanTrcv_Tja1145_GetBaudrateOfPnCfg(Index)                  (CanTrcv_Tja1145_PnCfg[(Index)].Baudrate)
#define CanTrcv_Tja1145_GetCanId0OfPnCfg(Index)                    (CanTrcv_Tja1145_PnCfg[(Index)].CanId0)
#define CanTrcv_Tja1145_GetCanId1OfPnCfg(Index)                    (CanTrcv_Tja1145_PnCfg[(Index)].CanId1)
#define CanTrcv_Tja1145_GetCanId2OfPnCfg(Index)                    (CanTrcv_Tja1145_PnCfg[(Index)].CanId2)
#define CanTrcv_Tja1145_GetCanId3OfPnCfg(Index)                    (CanTrcv_Tja1145_PnCfg[(Index)].CanId3)
#define CanTrcv_Tja1145_GetCanIdMask0OfPnCfg(Index)                (CanTrcv_Tja1145_PnCfg[(Index)].CanIdMask0)
#define CanTrcv_Tja1145_GetCanIdMask1OfPnCfg(Index)                (CanTrcv_Tja1145_PnCfg[(Index)].CanIdMask1)
#define CanTrcv_Tja1145_GetCanIdMask2OfPnCfg(Index)                (CanTrcv_Tja1145_PnCfg[(Index)].CanIdMask2)
#define CanTrcv_Tja1145_GetCanIdMask3OfPnCfg(Index)                (CanTrcv_Tja1145_PnCfg[(Index)].CanIdMask3)
#define CanTrcv_Tja1145_GetFrameControlOfPnCfg(Index)              (CanTrcv_Tja1145_PnCfg[(Index)].FrameControl)
#define CanTrcv_Tja1145_IsPnEnabled(Index)                         ((CanTrcv_Tja1145_PnEnabled[(Index)]) != FALSE)
#define CanTrcv_Tja1145_GetDataMask0OfPnPayloadCfg(Index)          (CanTrcv_Tja1145_PnPayloadCfg[(Index)].DataMask0)
#define CanTrcv_Tja1145_GetDataMask1OfPnPayloadCfg(Index)          (CanTrcv_Tja1145_PnPayloadCfg[(Index)].DataMask1)
#define CanTrcv_Tja1145_GetDataMask2OfPnPayloadCfg(Index)          (CanTrcv_Tja1145_PnPayloadCfg[(Index)].DataMask2)
#define CanTrcv_Tja1145_GetDataMask3OfPnPayloadCfg(Index)          (CanTrcv_Tja1145_PnPayloadCfg[(Index)].DataMask3)
#define CanTrcv_Tja1145_GetDataMask4OfPnPayloadCfg(Index)          (CanTrcv_Tja1145_PnPayloadCfg[(Index)].DataMask4)
#define CanTrcv_Tja1145_GetDataMask5OfPnPayloadCfg(Index)          (CanTrcv_Tja1145_PnPayloadCfg[(Index)].DataMask5)
#define CanTrcv_Tja1145_GetDataMask6OfPnPayloadCfg(Index)          (CanTrcv_Tja1145_PnPayloadCfg[(Index)].DataMask6)
#define CanTrcv_Tja1145_GetDataMask7OfPnPayloadCfg(Index)          (CanTrcv_Tja1145_PnPayloadCfg[(Index)].DataMask7)
#define CanTrcv_Tja1145_GetCanTrcvSpiChRWData_0(Index)             (CanTrcv_Tja1145_SpiChannelCfg[(Index)].CanTrcvSpiChRWData_0)
#define CanTrcv_Tja1145_GetCanTrcvSpiChRWData_1(Index)             (CanTrcv_Tja1145_SpiChannelCfg[(Index)].CanTrcvSpiChRWData_1)
#define CanTrcv_Tja1145_GetCanTrcvSpiChRWData_2(Index)             (CanTrcv_Tja1145_SpiChannelCfg[(Index)].CanTrcvSpiChRWData_2)
#define CanTrcv_Tja1145_GetCanTrcvSpiChRWData_3(Index)             (CanTrcv_Tja1145_SpiChannelCfg[(Index)].CanTrcvSpiChRWData_3)
#define CanTrcv_Tja1145_GetCanTrcvSeqRWDataLarge(Index)            (CanTrcv_Tja1145_SpiSequenceCfg[(Index)].CanTrcvSeqRWDataLarge)
#define CanTrcv_Tja1145_GetCanTrcvSeqRWDataMedium(Index)           (CanTrcv_Tja1145_SpiSequenceCfg[(Index)].CanTrcvSeqRWDataMedium)
#define CanTrcv_Tja1145_GetCanTrcvSeqRWDataNormal(Index)           (CanTrcv_Tja1145_SpiSequenceCfg[(Index)].CanTrcvSeqRWDataNormal)
#define CanTrcv_Tja1145_IsWakeupByBusUsed(Index)                   ((CanTrcv_Tja1145_WakeupByBusUsed[(Index)]) != FALSE)

#define CanTrcv_Tja1145_GetWakeupSource(Index)                     ((EcuM_WakeupSourceType)CanTrcv_Tja1145_WakeupSource[(Index)])
#define CanTrcv_Tja1145_GetWuSrcPor(Index)                         ((EcuM_WakeupSourceType)CanTrcv_Tja1145_WuSrcPor[(Index)])
#define CanTrcv_Tja1145_GetWuSrcSyserr(Index)                      ((EcuM_WakeupSourceType)CanTrcv_Tja1145_WuSrcSyserr[(Index)])

#ifdef __cplusplus
}
#endif
#endif
{{ "" }}